<?php


declare (strict_types=1);

namespace app\store\controller;

use app\store\model\Region as RegionModel;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;

/**
 * 地区管理
 * Class Region
 * @package app\store\controller
 */
class Region extends Controller
{
    /**
     * 获取所有地区
     * @return array
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function all()
    {
        $list = RegionModel::getCacheAll();
        return $this->renderSuccess(compact('list'));
    }

    /**
     * 获取所有地区(树状)
     * @return array
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function tree()
    {
        $list = RegionModel::getCacheTree();
        return $this->renderSuccess(compact('list'));
    }

}
